package cn.hallele.ms.portalcenter.api;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hallele.infrastructure.metadata.io.Page;
import cn.hallele.infrastructure.metadata.io.R;
import cn.hallele.infrastructure.metadata.io.Response;
import cn.hallele.mc.sdk.portalcenter.api.DataDictApi;
import cn.hallele.mc.sdk.portalcenter.common.constants.ReqPathConst;
import cn.hallele.mc.sdk.portalcenter.dto.DataDictTypeDTO;
import cn.hallele.mc.sdk.portalcenter.dto.DataDictTypeQueryDTO;
import cn.hallele.ms.infrastructure.auditlog.annotation.ApiLog;
import cn.hallele.ms.portalcenter.das.DataDictTypeDBDas;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * hallele_ms_configcenter
 *
 * @author anle5
 * @since 2025/3/9 16:04
 */
@RestController
@RequestMapping(ReqPathConst.DATA_DICT_V1)
public class DataDictController implements DataDictApi {
    @Autowired
    private DataDictTypeDBDas dataDictTypeDBDas;

    /**
     * 获取 数据字典列表
     *
     * @param condition 查询条件
     * @return List
     */
    @Override
    @SaCheckLogin
    @ApiLog(id = "DATA_DICT_V1_PAGE_DATA_DICT_LIST")
    public Response<Page<DataDictTypeDTO>> pageDataDictTypes(@Valid DataDictTypeQueryDTO condition) {
        Page<DataDictTypeDTO> result = dataDictTypeDBDas.getDataDictTypes(condition);
        return R.ok(result);
    }
}
